package org.example.day;

/**
 * @Description: TODO
 * @Author wyatt
 * @Data 2024/06/20 20:04
 */
public class Solution2748 {

    public static void main(String[] args) {
        Solution2748 solution = new Solution2748();
        System.out.println(solution.countBeautifulPairs(new int[]{2,5,1,4}));
    }

    public int countBeautifulPairs(int[] nums) {
        int count = 0;
        for (int i = 0; i < nums.length-1; i++) {
            while(nums[i] >= 10){
                nums[i] /= 10;
            }
            for (int j = i+1; j < nums.length; j++) {
                if (gcd(nums[i], nums[j] % 10) == 1) {
                    count++;
                }
            }
        }
        return count;
    }

    public int gcd(int a, int b){
        while (b != 0){
            int temp = b;
            b = a % b;
            a = temp;
        }
        return a;
    }

}
